import 'package:flutter/rendering.dart';

import '../index.dart';


class LoginRoute extends StatefulWidget {
  @override
  _LoginRouteState createState() => _LoginRouteState();
}

class _LoginRouteState extends State<LoginRoute> {


  TextEditingController _unameController = TextEditingController();
  TextEditingController _pwdController =  TextEditingController();

  @override
  void initState() {

    super.initState();

  }

  @override
  Widget build(BuildContext context) {
    
    return Scaffold(
      appBar: AppBar(
        title: Text('login'),
      ),
      body: Center(
        child: Column(
          children: [
            CustomTextField(icon: Icons.person, placeholder: '请输入用户名'),
            CustomTextField(icon: Icons.lock, placeholder: '请输入密码'),
            Padding(
              padding: EdgeInsets.only(top: 100),
              child: FlatButton(
                        padding: EdgeInsets.fromLTRB(100, 10, 100, 10),
                        color: Colors.blue,
                        onPressed: (){

                          showDialog(
                              context: context,
                              builder: (ctx) {
                                return AlertDialog(
                                  content: Text('登录成功'),
                                  actions: <Widget>[
                                    FlatButton(
                                      child: Text('取消'),
                                      onPressed: () => Navigator.pop(context),
                                    ),
                                    FlatButton(
                                      child: Text('确定'),
                                      onPressed: () {
                                        Navigator.pop(context);
                                        Navigator.pushNamed(context, "home_page");

                                      },
                                    ),
                                  ],
                                );
                              });
                        },
                        child: Text('登录注册',style: TextStyle(color: Colors.white)),

                      ),
            ),
          ],
        ),

      ),

    );
  }
}






class CustomTextField extends StatelessWidget {
  const CustomTextField({
    @required this.icon,
    @required  this.placeholder,
    this.text,
  });
  final IconData icon;
  final String placeholder;
  final String text;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      padding: EdgeInsets.all(20),
      color: Colors.white,
      child: TextFormField(
        decoration: InputDecoration(
          prefixIcon: Icon(icon),
          labelText: text,
          hintText: placeholder,
        ),

      ),
    );
  }

}



